<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>{$head[title]}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="{$head[keywords]}" name="keywords" />
<meta content="{$head[description]}" name="description" />
<base href="{SITE_URL}" />
<link href="favicon.ico" rel="shortcut icon" />
<link href="skin/style.css" rel="stylesheet" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="{$head[title]}" href="/rss.php?rssid={$catid}" />
<script language="JavaScript" src="misc/config.js"></script>
<script language="JavaScript" src="misc/jquery.min.js"></script>
<script language="JavaScript" src="misc/common.js"></script>
<script language="JavaScript" src="misc/validator.js"></script>
</head>
<body>

{template 'header.html'}

<div class="container">
	
    <div class="main"> 
    
        <p id="position"> <strong>当前位置：</strong><a href="">首页</a><a href="{$MODULE[member][url]}">会员中心</a><a href="{$M[url]}">订单</a>在线下单</p>
        <div class="head">订单信息></div>
        <form action="{url("?module=order&action=confirm")}" method="post" name="myform" id ="myform">
        <input type="hidden" name="goodsid" value="{$goodsid}" />
        <input type="hidden" name="goodsname" value="{$goodsname}" />
        <input type="hidden" name="goodsurl" value="{$goodsurl}" />
        <input type="hidden" name="unit" value="{$unit}" />
        <input type="hidden" name="price" value="{$price}" />
        <input type="hidden" name="carriage" value="{$carriage}" />
        <input type="hidden" name="stock" value="{$stock}" />
        <input type="hidden" name="verify" value="{$verify}" />
        <input type="hidden" name="forward" value="{$forward}" />
        <input type="hidden" name="isnewdeliver" value="{if $delivers}0{else}1{/if}" />
        <table cellpadding="0" cellspacing="1" class="table">
          <tr>
            <th width="15%">产品ID：</th>
            <td>{$goodsid}</td>       
          </tr>
          <tr>
            <th>产品名称：</th>
            <td><a href="{$goodsurl}" target="_blank">{$goodsname}</a></td>       
          </tr>
    {if $carriage}
          <tr>
            <th>产品运费：</th>
            <td>￥{$carriage}元</td>       
          </tr>
    {/if}
          <tr>
            <th>产品单价：</th>
            <td>￥{$price}元/{$unit}</td>       
          </tr>
    {if $stock}
          <tr>
            <th>库存：</th>
            <td>{$stock} {$unit}</td>       
          </tr>
          <tr>
            <th><font color="red">*</font> 订购数量：</th>
            <td><input type="text" name="number" value="{$number}" size="6" require="true" datatype="range|number" max="{$stock}" msg="当前库存数量为{$stock}，请重新填写|请填写正确的数量" msgid="msg_number"/> {$unit}<span id="msg_number"></span></td>       
          </tr>
    {else}
          <tr>
            <th><font color="red">*</font> 订购数量：</th>
            <td><input type="text" name="number" value="{$number}" size="6" require="true" datatype="number" msg="请填写正确的数量" msgid="msg_number"/> {$unit}<span id="msg_number"></span></td>       
          </tr>
    {/if}
          <tr>
            <th>给卖家留言：</th>
            <td><textarea name="note" id="note" rows="4" cols="60"></textarea></td>       
          </tr>
        </table>
    {if $delivers}
    
    <div class="head">确认您的收货地址</div>
        <table cellpadding="0" cellspacing="1" class="table_list"> 
          <tr>
            <th width="60">收货人</th>
            <th width="60">配送区域</th>
            <th width="90">电话</th>
            <th width="90">手机</th>
            <th>地址</th>
            <th width="50">邮编</th>
            <th width="80">操作</th>
          </tr>
    {loop $delivers $k $d}
          <tr>
            <td><input type="radio" name="deliverid" value="{$d[deliverid]}" {if $k==0}checked{/if} onClick="set_deliverid(this.value);"/></td>
            <td id="consignee_{$d[deliverid]}">{$d[consignee]}</td>
            <td>{$AREA[$d[areaid]][name]}<input type="hidden" name="areaid_{$d[deliverid]}" id="areaid_{$d[deliverid]}" value="{$d[areaid]}"><input type="hidden" name="areaname_{$d[deliverid]}" id="areaname_{$d[deliverid]}" value="{$AREA[$d[areaid]][name]}"></td>
            <td id="telephone_{$d[deliverid]}">{$d[telephone]}</td>
            <td id="mobile_{$d[deliverid]}">{$d[mobile]}</td>
            <td id="address_{$d[deliverid]}">{$d[address]}</td>
            <td id="postcode_{$d[deliverid]}">{$d[postcode]}</td>
          </tr>
    {/loop}
       </table>
    {/if}
    
    <div class="head">{if $delivers}新增{/if}收货地址</div>
    <table cellpadding="0" cellspacing="1" id="newdeliver" style="display:{if $delivers}none{/if}" class="table"> 
          <tr>
            <th width="15%"><font color="red">*</font> 配送区域：</th>
            <td>
                <input type="hidden" name="d[areaid]" id="areaid" value="{$areaid}">
          {if $areaid}
                <span id="areaname" style="cursor:pointer;" onClick="this.style.display='none';$('#reselect_areaid').show();">{$AREA[$areaid][name]} <font color="red">点击重选</font></span>
                <span id="reselect_areaid" style="display:none;">
                <span id="load_areaid"></span> 
                <a href="javascript:areaid_reload();">重选</a>
                </span>
          {else}
                <span id="load_areaid"></span>
                <a href="javascript:areaid_reload();">重选</a>
          {/if}
            </td> 
          </tr>
          <tr>
            <th><font color="red">*</font> 收货人：</th>
            <td><input type="text" name="d[consignee]" id="consignee" value="{$consignee}" size="12" require="true" datatype="require" msg="请填写收货人"/></td>       
          </tr>
          <tr>
            <th><font color="red">*</font> 电话：</th>
            <td><input type="text" name="d[telephone]" id="telephone" value="{$telephone}" size="20" require="true" datatype="custom" regexp="^[\d|\-|\+]{3,20}$"  msg="请填写正确的电话" msgid="telephone_notice"/> 格式：010-10000000-801 <span id="telephone_notice"></span></td>     
          </tr>
          <tr>
            <th><font color="red">*</font> 手机：</th>
            <td><input type="text" name="d[mobile]" id="mobile" value="{$mobile}" size="20" require="true" datatype="mobile" msg="请填写正确的手机" msgid="mobile_notice"/> 格式：13800000000 <span id="mobile_notice"></span></td>       
          </tr>
          <tr>
            <th><font color="red">*</font> 地址：</th>
            <td><input type="text" name="d[address]" id="address" value="{$address}" size="60" require="true" datatype="require" msg="填写正确的地址"/></td>       
          </tr>
          <tr>
            <th><font color="red">*</font> 邮编：</th>
            <td><input type="text" name="d[postcode]" id="postcode" value="{$postcode}" size="8" require="true" datatype="zip" msg="填写正确的邮编" msgid="postcode_notice"/> 格式：100000 <span id="postcode_notice"></span></td>       
          </tr>
    </table>
    {if $delivers}
        <div class="button_box" style="padding-left:10px"><input type="button" name="dosubmit" value="新增收货地址" style="width:100px" onClick="add_deliver();" />&nbsp;&nbsp;<input type="submit" name="dosubmit" value=" 下一步 " /></div>
    {else}
        <div class="button_box" style="padding-left:120px"><input type="submit" name="dosubmit" value=" 下一步 " /></div>
    {/if}
       </form>	
    
    </div>
    
    
    <div class="aside">
    	{template 'left.html','order'}
    </div>
    
    
</div>
    
     
{template 'footer.html'}
<script language="javascript" type="text/javascript">
$().ready(function() {
	  {if $delivers}
	  change_deliver('false');
	  set_deliverid(deliverid);
	  {/if}
	  $('form').checkForm(1);
});

var deliverid = '{$delivers[0][deliverid]}';
function set_deliverid(deliverid)
{
	$('#areaid').val($('#areaid_'+deliverid).val());
	$('#areaname').val($('#areaname_'+deliverid).val());
	$('#consignee').val($('#consignee_'+deliverid).html());
	$('#telephone').val($('#telephone_'+deliverid).html());
	$('#mobile').val($('#mobile_'+deliverid).html());
	$('#address').val($('#address_'+deliverid).html());
	$('#postcode').val($('#postcode_'+deliverid).html());
}

function add_deliver()
{
    $('#newdeliver').show();
    $('#isnewdeliver').val('1');
	change_deliver('true');
}

function change_deliver(val)
{
    $('#consignee').attr('require', val);
    $('#telephone').attr('require', val);
    $('#mobile').attr('require', val);
    $('#address').attr('require', val);
    $('#postcode').attr('require', val);
	$('form').checkForm(1);
}

function areaid_load(id)
{
	$.get("?module=area&action=load", { field: 'areaid', id: id }, function(data){
		$('#load_areaid').append(data);
	});
}

function areaid_reload()
{
	$('#load_areaid').html('');
	areaid_load(0);
}
areaid_reload();
</script>